package com.shujia.flink.tf

import org.apache.flink.api.common.functions.MapFunction
import org.apache.flink.streaming.api.scala._

object Demo1Map {

  def main(args: Array[String]): Unit = {

    val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment


    val ds: DataStream[String] = env.socketTextStream("master", 8888)

    ///scala的写法
    //    val ds3: DataStream[String] = ds.map(line => line + ":map")

    //java 的写法
    val ds1: DataStream[String] = ds.map(new MapFunction[String, String] {
      override def map(value: String): String = {
        println(value)
        value + ":map"
      }
    })

    //ds1.print()

    /**
      * flink程序没有转换算子和操作算子的区别
      * 但是最后需要 execute 启动flink的程序
      *
      */

    env.execute()

  }

}
